//
//  WriteViewController.m
//  LoginController
//
//  Created by wenzhaoxu on 15/11/18.
//  Copyright © 2015年 wenzhaoxu. All rights reserved.
//

#import "WriteViewController.h"

@interface WriteViewController ()<UITableViewDelegate,UITableViewDataSource>

@property NSString * identifier;

@end

@implementation WriteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置右侧按钮标题方式
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(editAction)];

    //设置右侧按钮标题方式
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"发表" style:UIBarButtonItemStylePlain target:self action:@selector(sendAction)];
    
    
    
}

-(void)editAction{

    //返回到前一级界面.注意： 必须是通过navigationController的push方式跳入进去的
    [self.navigationController popViewControllerAnimated:YES];

}

-(void)sendAction{

    [self.navigationController popViewControllerAnimated:YES];
}

//返回节
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 2;
}
//返回行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (section==0) {
        return 2;
    }else{
        return 1;
    }
}

//渲染行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section==0) {
        if (indexPath.row==0) {
            self.identifier =@"cell1";
        }else{
            self.identifier = @"cell2";
        }
    }else{
        self.identifier = @"cell2";
    }
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:self.identifier];
    
    if (indexPath.section==0) {

        if (indexPath.row==1) {
            UILabel * label1 = (UILabel *)[cell viewWithTag:11];
            label1.text =@"地点";
            UILabel * label2 = (UILabel *)[cell viewWithTag:12];
            label2.text =@" ";
            cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
        }
        
    }else{
        UILabel * label1 = (UILabel *)[cell viewWithTag:11];
        label1.text =@"谁能看见";
        UILabel * label2 = (UILabel *)[cell viewWithTag:12];
        label2.text =@"所有人可见";
         cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
    }
    
    
    return cell;

}
#pragma mark - UITableViewDataSource
//返回Cell的高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section==0) {
        if (indexPath.row==0) {
            return 162;
        }else{
            return 43;
        }
    }else{
        return 43;
    }

}
//选中状态
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

}


//- (IBAction)pice:(id)sender {
//    
//    [self performSegueWithIdentifier:@"pice" sender:nil];
//    
//}




@end
